


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
  <title>Coverage Report :: Park</title>
  <style type="text/css">
    @import "../../.css/coverage.css";
  </style>
</head>

<body>
<div class="header"></div>

<div class="content">
<div class="breadCrumbs">
    [ <a href="../../index.html">all classes</a> ]
    [ <a href="../index.html">second.group.bering.parking_system</a> ]
</div>

<h1>Coverage Summary for Class: Park (second.group.bering.parking_system)</h1>

<table class="coverageStats">

<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">Park</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (6/ 6)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (13/ 13)
  </span>
</td>
</tr>
  <tr>
    <td class="name">Park$_exists_closure2</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
  </tr>
  <tr>
    <td class="name">Park$_hasCar_closure1</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
  </tr>
  <tr>
    <td class="name">Park$availableLocation$4</td>
  </tr>
  <tr>
    <td class="name">Park$exists$3</td>
  </tr>
  <tr>
    <td class="name">Park$hasCar$1</td>
  </tr>
  <tr>
    <td class="name">Park$hasLocation$0</td>
  </tr>
  <tr>
    <td class="name">Park$parking</td>
  </tr>
  <tr>
    <td class="name">Park$pickup$2</td>
  </tr>
<tr>
  <td class="name"><strong>total</strong></td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (8/ 8)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (15/ 15)
  </span>
</td>
</tr>
</table>

<br/>
<br/>


<div class="sourceCode"><i>1</i>&nbsp;package second.group.bering.parking_system
<i>2</i>&nbsp;
<i>3</i>&nbsp;import second.group.bering.parking_system.model.Car;
<i>4</i>&nbsp;/**
<i>5</i>&nbsp; *
<i>6</i>&nbsp; * Park
<i>7</i>&nbsp; *
<i>8</i>&nbsp; * @author Burgess Li, Thomas Chen
<i>9</i>&nbsp; * @date 8/23/2018 2:39 PM
<i>10</i>&nbsp; * @version 1.0
<i>11</i>&nbsp; *
<i>12</i>&nbsp; */
<i>13</i>&nbsp;class Park {
<i>14</i>&nbsp;
<i>15</i>&nbsp;    String id
<i>16</i>&nbsp;    Integer size = 0
<i>17</i>&nbsp;    Map&lt;String, Car&gt; cars = [:]
<i>18</i>&nbsp;
<i>19</i>&nbsp;    /**
<i>20</i>&nbsp;     * Task #1
<i>21</i>&nbsp;     * @param car
<i>22</i>&nbsp;     * @return parking result
<i>23</i>&nbsp;     */
<i>24</i>&nbsp;    boolean parking(Car car) {
<b class="fc"><i>25</i>&nbsp;        if (car &amp;&amp; hasLocation() &amp;&amp; !cars.containsKey(car.number)) {</b>
<b class="fc"><i>26</i>&nbsp;            cars[car.number] = car</b>
<b class="fc"><i>27</i>&nbsp;            return true</b>
<i>28</i>&nbsp;        }
<b class="fc"><i>29</i>&nbsp;        return false</b>
<i>30</i>&nbsp;    }
<i>31</i>&nbsp;
<i>32</i>&nbsp;    boolean hasLocation() {
<b class="fc"><i>33</i>&nbsp;        return cars.size() &lt; this.size</b>
<i>34</i>&nbsp;    }
<i>35</i>&nbsp;
<i>36</i>&nbsp;    boolean hasCar(String carNumber) {
<b class="fc"><i>37</i>&nbsp;        return this.cars.keySet().any { it == carNumber }</b>
<i>38</i>&nbsp;    }
<i>39</i>&nbsp;
<i>40</i>&nbsp;    int availableLocation() {
<b class="fc"><i>41</i>&nbsp;        return this.size - cars.size()</b>
<i>42</i>&nbsp;    }
<i>43</i>&nbsp;
<i>44</i>&nbsp;    boolean exists(Car car) {
<b class="fc"><i>45</i>&nbsp;        return this.cars.values().any { it.number == car.number }</b>
<i>46</i>&nbsp;    }
<i>47</i>&nbsp;
<i>48</i>&nbsp;    /**
<i>49</i>&nbsp;     * Task #2
<i>50</i>&nbsp;     * @param carNumber
<i>51</i>&nbsp;     * @return car
<i>52</i>&nbsp;     */
<i>53</i>&nbsp;    Car pickup(String carNumber) {
<b class="fc"><i>54</i>&nbsp;        if (carNumber &amp;&amp; cars[carNumber]) {</b>
<b class="fc"><i>55</i>&nbsp;            Car car = cars[carNumber]</b>
<b class="fc"><i>56</i>&nbsp;            cars.remove(carNumber)</b>
<b class="fc"><i>57</i>&nbsp;            return car</b>
<i>58</i>&nbsp;        }
<b class="fc"><i>59</i>&nbsp;        return null</b>
<i>60</i>&nbsp;    }
<i>61</i>&nbsp;
<i>62</i>&nbsp;}
</div>
</div>

<div class="footer">
    
    <div style="float:right;">generated on 2018-08-24 14:25</div>
</div>
</body>
</html>
